<template>
  <div>
    <div>
      <el-button @click="save">保存</el-button>
    </div>
    <div>
      <!-- <tinymce v-model="content" :height="300" /> -->
      <!-- <div id="aiEditor" ref="divRef" style="height: 600px" /> -->
    </div>
  </div>
</template>

<script>

import { getFilePreview, modifyFileContent } from '_r/file.js'

//import { AiEditor } from "../../node_modules/aieditor/dist/index.js";
//import "../../node_modules/aieditor/dist/style.css"
//import Tinymce from '@/components/Tinymce'
export default {
  components: {
    //Tinymce
  },
  data() {
    return {
      content: '',
      userFileId: '',
    }
  },
  mounted() {
  },
  created() {
    this.userFileId = this.$route.query.userFileId
    this.getCodeText()
  },
  methods: {
    save() {
      modifyFileContent({ userFileId: this.userFileId, fileContent: this.content })
    },
    /**
 * 获取代码文本内容
 */
    getCodeText() {
      getFilePreview({
        userFileId: this.$route.query.userFileId,
        isMin: false,
        token: this.$common.getCookies(this.$config.tokenKeyName)
      }).then((res) => {
        this.content =
          typeof res === 'object' ? JSON.stringify(res) : res
        this.codeMirrorText = this.originalCodeText + ''
      })
    },
  }
}
</script>
<script type="module">
//import {AiEditor} from 'aieditor/dist/index.js'
new AiEditor({
    element: "#aiEditor",
    placeholder: "点击输入内容...",
    content: 'AiEditor 是一个面向 AI 的下一代富文本编辑器。',
    ai: {
        model: {
            xinghuo: {
                appId: "***",
                apiKey: "***",
                apiSecret: "***",
            }
        }
    },
})
</script>
<style scoped>
.editor-content {
  margin-top: 20px;
}
</style>